LocalAuthGuard   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 13
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A canActivate 0 7 1
1
import { ExecutionContext, Injectable } from '@nestjs/common';
2
import { AuthGuard } from '@nestjs/passport';
3
import { Request } from 'express';
4
5
@Injectable()
6
export class LocalAuthGuard extends AuthGuard('local') {
7
  constructor() {
8
    super();
9
  }
10
11
  async canActivate(context: ExecutionContext): Promise<boolean> {
12
    // Perform log in using LocalStrategy
13
    await super.canActivate(context);
14
    const request = context.switchToHttp().getRequest() as Request;
15
    await super.logIn(request);
16
    return true;
17
  }
18
}
19